package org.sport.model.entityModel;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Collection;

/**
 * Created by Allen on 2017/9/29.
 */
@Entity
@Table(name = "sporthistorytable", schema = "sportinfo", catalog = "")
public class SporthistorytableEntity {
    private int id;
    private Timestamp startTiem;
    private Timestamp endTime;
    private String spoType;
    private Double spoDis;
    private Double airQua;
    private Double aveSpeed;
    private Double calorie;
    private Integer stepNumer;
    private Double duration;
    private UsertableEntity usertableByUserId;
    private Collection<LocationtableEntity> locationtablesById;

    @Id
    @Column(name = "_id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "startTiem", nullable = true)
    public Timestamp getStartTiem() {
        return startTiem;
    }

    public void setStartTiem(Timestamp startTiem) {
        this.startTiem = startTiem;
    }

    @Basic
    @Column(name = "endTime", nullable = true)
    public Timestamp getEndTime() {
        return endTime;
    }

    public void setEndTime(Timestamp endTime) {
        this.endTime = endTime;
    }

    @Basic
    @Column(name = "spoType", nullable = true, length = 45)
    public String getSpoType() {
        return spoType;
    }

    public void setSpoType(String spoType) {
        this.spoType = spoType;
    }

    @Basic
    @Column(name = "spoDis", nullable = true, precision = 0)
    public Double getSpoDis() {
        return spoDis;
    }

    public void setSpoDis(Double spoDis) {
        this.spoDis = spoDis;
    }

    @Basic
    @Column(name = "airQua", nullable = true, precision = 0)
    public Double getAirQua() {
        return airQua;
    }

    public void setAirQua(Double airQua) {
        this.airQua = airQua;
    }

    @Basic
    @Column(name = "aveSpeed", nullable = true, precision = 0)
    public Double getAveSpeed() {
        return aveSpeed;
    }

    public void setAveSpeed(Double aveSpeed) {
        this.aveSpeed = aveSpeed;
    }

    @Basic
    @Column(name = "calorie", nullable = true, precision = 0)
    public Double getCalorie() {
        return calorie;
    }

    public void setCalorie(Double calorie) {
        this.calorie = calorie;
    }

    @Basic
    @Column(name = "stepNumer", nullable = true)
    public Integer getStepNumer() {
        return stepNumer;
    }

    public void setStepNumer(Integer stepNumer) {
        this.stepNumer = stepNumer;
    }

    @Basic
    @Column(name = "duration", nullable = true, precision = 0)
    public Double getDuration() {
        return duration;
    }

    public void setDuration(Double duration) {
        this.duration = duration;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        SporthistorytableEntity that = (SporthistorytableEntity) o;

        if (id != that.id) return false;
        if (startTiem != null ? !startTiem.equals(that.startTiem) : that.startTiem != null) return false;
        if (endTime != null ? !endTime.equals(that.endTime) : that.endTime != null) return false;
        if (spoType != null ? !spoType.equals(that.spoType) : that.spoType != null) return false;
        if (spoDis != null ? !spoDis.equals(that.spoDis) : that.spoDis != null) return false;
        if (airQua != null ? !airQua.equals(that.airQua) : that.airQua != null) return false;
        if (aveSpeed != null ? !aveSpeed.equals(that.aveSpeed) : that.aveSpeed != null) return false;
        if (calorie != null ? !calorie.equals(that.calorie) : that.calorie != null) return false;
        if (stepNumer != null ? !stepNumer.equals(that.stepNumer) : that.stepNumer != null) return false;
        if (duration != null ? !duration.equals(that.duration) : that.duration != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + (startTiem != null ? startTiem.hashCode() : 0);
        result = 31 * result + (endTime != null ? endTime.hashCode() : 0);
        result = 31 * result + (spoType != null ? spoType.hashCode() : 0);
        result = 31 * result + (spoDis != null ? spoDis.hashCode() : 0);
        result = 31 * result + (airQua != null ? airQua.hashCode() : 0);
        result = 31 * result + (aveSpeed != null ? aveSpeed.hashCode() : 0);
        result = 31 * result + (calorie != null ? calorie.hashCode() : 0);
        result = 31 * result + (stepNumer != null ? stepNumer.hashCode() : 0);
        result = 31 * result + (duration != null ? duration.hashCode() : 0);
        return result;
    }

    @ManyToOne
    @JoinColumn(name = "userId", referencedColumnName = "_id")
    public UsertableEntity getUsertableByUserId() {
        return usertableByUserId;
    }

    public void setUsertableByUserId(UsertableEntity usertableByUserId) {
        this.usertableByUserId = usertableByUserId;
    }

    @OneToMany(mappedBy = "sporthistorytableBySpohisId")
    public Collection<LocationtableEntity> getLocationtablesById() {
        return locationtablesById;
    }

    public void setLocationtablesById(Collection<LocationtableEntity> locationtablesById) {
        this.locationtablesById = locationtablesById;
    }

    @Override
    public String toString() {
        return "SporthistorytableEntity{" +
                "id=" + id +
                ", startTiem=" + startTiem +
                ", endTime=" + endTime +
                ", spoType='" + spoType + '\'' +
                ", spoDis=" + spoDis +
                ", airQua=" + airQua +
                ", aveSpeed=" + aveSpeed +
                ", calorie=" + calorie +
                ", stepNumer=" + stepNumer +
                ", duration=" + duration +
                ", usertableByUserId=" + usertableByUserId +
                '}';
    }
}
